package cn.jietuo.first.class02;


/**
 * @author zhangx & jietuo_zx@163.com
 * @version 1.0
 * @date 2020/6/16
 * @description: 单链表反转
 */
public class Code01_NodeReversal {


    public Node reversalLinkedList(Node head) {
        Node pre = null;
        Node next = null;
        while (head != null) {
            next = head.next;
            head.next = pre;
            pre = head;
            head = next;
        }
        return pre;
    }

    public DoubleNode reversalDoubleNode(DoubleNode head) {
        DoubleNode pre = null;
        DoubleNode next = null;
        while (head != null) {
            next = head.next;
            head.pre = next;
            head.next = pre;
            pre = head;
            head = next;
        }
        return pre;
    }


}
